home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #14
/
Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO
/
pcboard
/
msgtag11.zip
/
MORE.PPS
< prev
next >
Wrap
Text File
|
1996-01-30
|
21KB
|
678 lines
;
; FLAG.PPE Original source written by David W. Terry
; NOTE: Please DO NOT DISTRIBUTE modified source code without prior permission
; or without meeting the requirements set forth in FLAG.DOC.
;
;──────────────────────────────────────────────────────────────────────────────
; MORE.PPE - Written by Dan Shore - SysOp
; The Shoreline BBS
;
; Modified FLAG.PPE by Dan Shore - July 2, 1995 to work with the
; msg tagging PPE's (QSCAN, MORE, MEC, READ, KILL, RECOVER)
;
; MORE.PPE meets the requirments for modification and re-distribution as
; set forth in the requirements in the "original" FLAG.DOC from FLAG32.ZIP.
;
; Purpose: Replacement of the More Prompt for use with the msg
; tagging PPE's (QSCAN, READ, KILL, RECOVER, MORE, MEC)
;
;──────────────────────────────────────────────────────────────────────────────
;
; Last Revised: 11-2-95
; Revised by : Dan Shore
; Revision : Removed total_msgs_tagged variable
;
;──────────────────────────────────────────────────────────────────────────────
;
; To install:
;
; 1) Edit your PCBText file and change the following entry:
;
; MKPCBTXT PCBTEXT /I:196 "!C:\PCB\PPE\QSCAN\MORE.PPE"
;
; Note: You may have to change the pathname to the PPE.
;
;──────────────────────────────────────────────────────────────────────────────
;
; Items to be completed yet with Message Tagging:
;
; 1. RIP Support
; 2. Support for 50 line mode
; 3. Support for more than 20 stacked message numbers for reading.
; 20 message number stacking is a limitation of PCB, so at this
; time we elected to keep the PPE within PCB limitations and add
; additional flexibility/features later on.
;
;──────────────────────────────────────────────────────────────────────────────
;
;
; check to see if caller has ANSI capabilities and, if not, display the old
; prompt and exit - let PCBoard handle the input.
;
IF (!ANSION()) THEN
DISPFILE PPEPATH()+"TAGOLD",LANG
END
ENDIF
BOOLEAN exitflag ' Flag to determine when we should exit
BOOLEAN rip ' Flag to indicate RIPscrip is in use
BOOLEAN end_of_screen ' Flag to indicate end of screen
BOOLEAN going_up ' Flag to indicate we are going up the screen
BOOLEAN found_dupe ' Flag for duplicate tagged msg checking
BOOLEAN max_tagged ' Flag to indicate maximum tagged messages reached
STRING text ' The text that the caller types
STRING key ' Keystroke text
STRING prev_key ' Save previous key
STRING hold ' garbage variable
STRING page_length_file ' file where users original page length is stored
STRING BS ' An ASCII backspace character
STRING BS2 ' An ASCII backspace character
STRING CR ' An ASCII carriage return character
STRING ESC ' An ASCII esc character
STRING tag_msg ' Variable for determining if msg has been tagged
STRING tag_msg_file ' Disk file tagged messages are written to
STRING sema_path ' Path to the semaphore file
STRING filename ' The name of the file that is being processed
STRING fileimage ' Includes the color codes for restoration of text
BIGSTR tag_msg_list ' Contains tagged message numbers seperated by
' semi-colon. This will then be written to
' the disk file for reading by KILL.PPE, RECOVER.PPE,
' READ.PPE and QSCAN.PPE
BIGSTR hold2 ' garbage variable
BYTE len ' Length of the text the caller has typed
BYTE oldy ' Last row position of cursor
BYTE newy ' New row position of cursor
BYTE topy ' top position of msg numbers
BYTE x ' garbage variable
BYTE int_temp ' Generic byte variable
;──────────────────────────────────────────────────────────────────────────────
hold = READLINE(PCBDAT(),204)
hold = FILEINF(hold,6) + ":" + FILEINF(hold,7)
sema_path = hold + "msgtag.use"
tag_msg_file = hold + "mtg" + STRING(CURCONF()) + ".lst"
page_length_file = hold + "userpl.dat"
'
' See if the disk file exists. If not show the "standard"
' more prompt and exit
'
' If the file does exist, get the tagged msg information from it and
' place the information into tag_msg_list variable
'
IF (!EXIST(sema_path)) THEN
DISPFILE PPEPATH() + "tagold", LANG+GRAPH
END
ELSE
IF (FILEINF(tag_msg_file,4) > 0) THEN
FOPEN 1, tag_msg_file, O_RD, S_DN
FREAD 1, tag_msg_list, FILEINF(tag_msg_file,4)
FCLOSE 1
END IF
END IF
; Initializations
BS = CHR(8) ' Backspace Key
BS2 = CHR(127) ' Alternate Backspace Key
CR = CHR(13) ' Carriage Return
ESC = CHR(27) ' ESC character
x = 1 ' Initialize screen line counter
'
' set the first 50 message numbers (lines on display) to not being tagged
'
tag_msg = "00000000000000000000000000000000000000000000000000"
;***********************************************************************
; Main Program
CLREOL ' clear the line for input
GOSUB displayprompt ' display the new prompt
' While the user hasn't exited, get keystrokes and act on them.
' Exiting will occur when the caller presses ENTER.
WHILE (!exitflag) DO
key = INKEY() ' Get a keypress from the user
if (key <> "") THEN ' If the user pressed a key, then let's process it
' If it is the FIRST keystroke, signified by the buffer having 0 bytes
' in it, then check to see if it is a SPACE. If so, then we'll go into
' MARK mode. If not, then we'll process the keystrokes the same way that
' PCBoard would .. gathering them up into a buffer. Once the ENTER key
' is pressed, we'll exit out and stuff PCBoard's keyboard buffer with the
' keystrokes that were collected.
IF (len = 0 && (key = " " || LEFT(key,2) = "UP" || LEFT(key,4) = "DOWN")) THEN
'
' Get the row we are curently in
'
oldy = GETY()
'
' Read the screen buffer to get the first line where a
' msg number appears
'
WHILE (1) DO
hold = SCRTEXT(1,x,5,FALSE)
IF (INSTR(hold,"Msg#") > 0) THEN
INC x
BREAK
ELSE IF (S2I(MID(hold,2,4),10) > 0) THEN
BREAK
ELSE
INC x
IF (x > 25) BREAK
END IF
END WHILE
newy = x
topy = x
IF (LEFT(key,2) = "UP") THEN
going_up = TRUE
newy = GETY() - 1
ELSE IF (key = " " || LEFT(key,4) = "DOWN") THEN
key = "DOWN"
going_up = FALSE
END IF
ANSIPOS 1, oldy
PRINT CR
CLREOL
PRINT ESC+"[s" ' save the current cursor position
' Let the caller know what he can do while in MARK mode
DISPFILE PPEPATH()+"TAGBAR",GRAPH+LANG
' Move the cursor back to the first column
PRINT CR
' Find the first msg number on the screen.
GOSUB findfile
'
' If a msg num was found, then findfile highlighted it. Now wait for
' another keystroke to see if the user whats to mark this one, or move
' on to another one, or exit out. Marking is done by pressing ENTER,
' moving to another file is done by pressing SPACE, UP or DOWN arrow,
' and exiting is done by pressing ESC.
'
IF (filename <> "") THEN
WHILE (1) DO
key = INKEY()
IF (key = ESC) BREAK
IF (key = CR) THEN
GOSUB unhighlight
GOSUB highlight
IF (going_up) THEN
INC newy
key = "UP"
ELSE
DEC newy
key = "DOWN"
END IF
GOSUB findfile
ELSEIF (key = " " || LEFT(key,4) = "DOWN" || LEFT(key,2) = "UP") THEN
' If the key pressed was a SPACE, UP or Down then the user
' has decided to skip
' over that msg. So unhighlight it, then try to find another
' msg. If a msg is found, we'll stay in this loop. If one is
' not found, then we'll restore the original prompt and go back to
' waiting for keystrokes in case the caller wants to start over
IF (key = " ") key = "DOWN"
IF (prev_key = "DOWN" && LEFT(key,2) = "UP") THEN
newy = newy - 2
ELSEIF (prev_key = "UP" && LEFT(key,4) = "DOWN") THEN
newy = newy + 2
END IF
GOSUB unhighlight
GOSUB findfile
IF (end_of_screen) THEN
GOSUB restorecursor
GOSUB displayprompt
end_of_screen = FALSE
GOTO bottom
ENDIF
ELSE ' addition per David Terry msg
DELAY 3 ' addition per David Terry msg
ENDIF
ENDWHILE
' If we've gotten this far, then ESC was pressed. We'll
' unhighlight the msg, restore the prompt and then, if CR was pressed,
' meaning the user wished to flag that msg
GOSUB unhighlight
GOSUB restorecursor
ELSE
GOSUB restorecursor
ENDIF
GOSUB displayprompt
CONTINUE
ELSEIF (key == BS | key == BS2) THEN
' If the caller pressed backspace or delete, then delete the character
' to the left, and remove it from the input buffer. Of course, if the
' caller hasn't typed anything yet, or if the caller has already
' backspaced everything out, signified by the len being 0 (meaning there
' are 0 bytes in the buffer), then we'll just loop back around waiting
' for more keystrokes
IF (len > 0) THEN
PRINT BS+" "
len = len - 1
text = LEFT(text,len)
ELSE
CONTINUE
ENDIF
ELSEIF (key = CR) THEN
'
' If it's a carriage return then set the flag to exit
'
exitflag = TRUE
'
ELSEIF (LEN(key) > 1 | key < " ") THEN
' Special keys, such as UP, DOWN, etc, return multi-letter values such
' as "UP" and "DOWN" when the INKEY() function is called. Since we just
' want to ignore special characters, we'll use the CONTINUE statement to
' jump back to the top of the loop
'
' We also want to avoid displaying "control characters" so anything
' less than a SPACE should also be skipped.
CONTINUE
ELSEIF ((len = 0) & ((key = "?") | (UPPER(key) = "H"))) THEN
' If the user typed "?" or "H" then we want to display a help file.
' First we'll save the current screen, then display the help file, and
' then restore the saved screen after the caller has read the help file.
SAVESCRN
NEWLINE
DISPFILE PPEPATH()+"TAGHLP",GRAPH+LANG
NEWLINE
WAIT
RESTSCRN
CONTINUE
ELSEIF ((key >= " ") & (len < 80)) THEN
' Here we are just gathering up keystrokes and putting them into an
' input buffer. As long as the keystrokes are greater than or equal to
' a SPACE we'll just add them in until a limit of 80 characters is
' reached. PCBoard won't let you type more than 80 characters at that
' prompt anyway so we might as well keep the same limit.
text = text + key
len = len + 1
ENDIF
PRINT key ' Print any keystrokes the caller types
ELSE ' addition per David Terry msg
DELAY 3 ' addition per David Terry msg
ENDIF
:bottom
ENDWHILE
' If we've gotten this far, then the caller has pressed ENTER so we'll stuff
' whatever the caller has typed into PCBoard's input buffer and let PCBoard
' process the request.
'
text = RTRIM(text," ")
'
' Move cursor back to left margin and clear the line in case the user
' has decided to flag files the old fashion way - "...they earn it..."
' no that isn't it!! - too much T.V. :) - if they use the FLAG command
' instead of the space bar or cursor arrow keys, remains of the previous
' prompt will remain if not cleared
'
PRINT CR
CLREOL
KBDSTUFF text+CR
IF (key = CR) CLS
'
' Delete the semaphore file if the user quit "N" the quick scan listing
' and also restore the users ORIGINAL page length settings
'
IF (INSTR(UPPER(text), "N") || INSTR(UPPER(text), "NS") || INSTR(UPPER(text), "A")) THEN
IF (EXIST(page_length_file)) THEN
GETUSER
FOPEN 7, page_length_file, O_RD, S_DN
FGET 7, hold
U_PAGELEN = TOINT(hold)
FCLOSE 7
PUTUSER
DELETE page_length_file
END IF
IF (FILEINF(tag_msg_file,4) = 0) DELETE tag_msg_file
DELETE sema_path
END IF
'
' If we have tagged files, write them to the disk file
'
IF (tag_msg_file != "" && LEN(tag_msg_list) > 0) THEN
FOPEN 1, tag_msg_file, O_WR, S_DN
FWRITE 1, tag_msg_list, LEN(tag_msg_list)
FCLOSE 1
END IF
END
;***********************************************************************
'
' This subroutine restores the cursor position. It does this using an ANSI
' command that simply restores a previously saved cursor position. In
' addition, we'll clear the line before returning.
:restorecursor
PRINT ESC+"[u"
CLREOL
RETURN
;***********************************************************************
'
' This is a subroutine that displays the new prompt and then sets the color to
' the default for input.
:displayprompt
DISPFILE PPEPATH()+"TAGNEW",LANG
DEFCOLOR
RETURN
;***********************************************************************
'
' This is a subroutine that checks the filenames() array to locate the next
' file on screen. If RIPscrip is used, then special commands (which are
' passed via a mouse-click from the caller's terminal, are used to identify
' which file is desired.
'
' If a valid filename is found, it is stored in a variable called filename.
' Also, it calls another subroutine to highlight the filename on the screen.
:findfile
'
' ***********************************************************
' RIP support not implemented yet!!!!! - Any Volunteers?????
' ***********************************************************
'
'IF (rip) THEN
' newy = 0
' key = ""
' WHILE (newy = 0) DO
' key = INKEY() ' watch for the next character
' newy = ASC(key)
' IF (newy >= 129 & newy <= 151) THEN
' newy = newy - 128
' IF (filenames(newy) <> "") THEN
' GOSUB highlight
' filename = filenames(newy)
' RETURN
' ELSE
' newy = 0
' ENDIF
' ELSE ' addition per David Terry msg
' DELAY 3 ' addition per David Terry msg
' ENDIF
' ENDWHILE
'ELSE
IF (LEFT(key,4) = "DOWN") THEN
IF (newy < oldy) THEN
going_up = FALSE
prev_key = "DOWN"
filename = SCRTEXT(1,newy,8,FALSE)
GOSUB highlight
INC newy
RETURN
ELSE
end_of_screen = TRUE
RETURN
ENDIF
END IF
IF (LEFT (key,2) = "UP") THEN
IF (newy > topy-1) THEN
prev_key = "UP"
going_up = TRUE
filename = SCRTEXT(1,newy,8,FALSE)
GOSUB highlight
DEC newy
RETURN
ELSE
end_of_screen = TRUE
RETURN
ENDIF
END IF
'ENDIF
' no valid msg num was found, return with an empty msg num
filename = ""
RETURN
;***********************************************************************
'
' This is a subroutine that highlights the msg num moving the cursor to the
' correct line and then changing the color to black on white and printing the
' msg num. Prior to highlighting the msg num, it saves a color image of the
' msg num so that, when it comes time to unhighlight the file, the image can
' be restored.
:highlight
'
' move the cursor back to where it started, at the bottom, and then move
' it up to the appropriate line on the screen.
'
IF (key = CR) THEN
IF (going_up) THEN
PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy-1)+"A"
int_temp = newy + 1
ELSE
PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy+1)+"A"
int_temp = newy - 1
END IF
'
' Check to see if the msg number is already marked
'
IF (MID(tag_msg,int_temp,1) = "1") THEN
filename = MID(filename,1,7) + " "
tag_msg = MID(tag_msg,1,int_temp-1) + "0" + MID(tag_msg,int_temp+1,50-int_temp)
GOSUB REMOVE_TAG
ELSE
'
' Check for duplicate msg number tagged
'
GOSUB CHECK_DUPE_TAG
IF (found_dupe) RETURN
'
' msg number gets added in this routine, if we have not exceeded
' the maximum number of msgs allowed to mark
'
GOSUB CHECK_MAX_TAG
IF (max_tagged) RETURN
'
' Print msg number again with an "*" to the right to show it is tagged
'
filename = MID(filename,1,7) + "*"
'
' change tag_msg to show the msg is now tagged
'
tag_msg = MID(tag_msg,1,int_temp-1) + "1" + MID(tag_msg,int_temp+1,50-int_temp)
END IF
ELSE
PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy)+"A"
COLOR @X70
END IF
' get the file image (text & attributes) for later restoration
fileimage = SCRTEXT(1,newy,8,TRUE)
' print the message number
PRINT filename + CR
RETURN
;***********************************************************************
'
' This is a subroutine that unhighlights the msg num by printing the file
' image, which includes color codes as well as the msg num.
:unhighlight
PRINT fileimage+CR
RETURN
'
' Removes a tagged msg from list and rebuilds the list
'
:REMOVE_TAG
hold = RTRIM(MID(filename,2,7)," ")
hold2 = MID(tag_msg_list,1,INSTR(tag_msg_list,hold)-1)
'
' If msg number to remove is the first number
'
IF (hold2 = "") THEN
int_temp = INSTR(tag_msg_list,";")+1
IF (int_temp >= LEN(tag_msg_list)) THEN
tag_msg_list = ""
ELSE
hold2 = hold2 + MID(tag_msg_list,int_temp,LEN(tag_msg_list)-int_temp+1)
END IF
ELSE
x = LEN(hold2)+LEN(hold)+2
IF (x < LEN(tag_msg_list)) hold2 = hold2 + MID(tag_msg_list, x, LEN(tag_msg_list)-INSTR(tag_msg_list,hold)+1)
END IF
tag_msg_list = hold2
RETURN
'
' Check to see if the msg number has already been tagged
'
:CHECK_DUPE_TAG
found_dupe = FALSE
IF (INSTR(tag_msg_list,RTRIM(MID(filename,2,6)," ")) != 0) THEN
IF (going_up) THEN
hold = SCRTEXT(1,newy+1,78,TRUE)
ELSE
hold = SCRTEXT(1,newy-1,78,TRUE)
END IF
CLREOL
PRINT "@X0CDuplicate Message Number...@X0FRequest ignored@X07"
DELAY 54
PRINT CR
CLREOL
PRINT hold
found_dupe = TRUE
END IF
RETURN
'
' Check to see if we have reached our tagged msg limit. This limit
' is due to the STRING variable tag_msg_list having a max of 256 chars.
'
:CHECK_MAX_TAG
max_tagged = FALSE
IF (LEN(tag_msg_list) + LEN(TRIM(MID(filename,2,6)," ")) < 2047) THEN
tag_msg_list = tag_msg_list + TRIM(MID(filename,2,6)," ") + ";"
ELSE
IF (going_up) THEN
hold = SCRTEXT(1,newy+1,78,TRUE)
ELSE
hold = SCRTEXT(1,newy-1,78,TRUE)
END IF
COLOR @X07
CLREOL
PRINT "@X0CMaximum of @X0F20@X0C Tagged Messages Reached @X0B- @X0FMessage not Tagged"
DELAY 54
PRINT CR
CLREOL
PRINT hold
max_tagged = TRUE
END IF
RETURN
;***********************************************************************
'
' This subroutine scans the screen at startup to see and fills an array called
' filenames() with the names of all files found on screen. If RIPscrip is in
' use, it will also send out RIPscrip commands to define the location of the
' filenames on screen so that the caller can use a mouse to point and click.
'
':scanforfiles
'IF (GRAFMODE() = "R") THEN
' rip = TRUE
'ENDIF
'
'newy = 1
'WHILE (newy > 0) DO
' ' get a filename off the screen ... if a filename is found, the filename
' ' variable will be updated, if no more filenames are found, newy will be
' ' set to 0.
' SCRFILE newy, filename
'
' IF (newy <> 0) THEN
' ' store the filename that was found into an array
' filenames(newy) = filename
'
' ' If in RIPscrip mode, define the mouse region where the filename is
' ' located. The coordinates are defined in X,Y coordinates of 0,newy and
' ' 13,newy+1. The X coordinate (0 to 13) defines the length of the name.
' ' The Y coordinate (newy to newy+1) defines the height of the name.
' ' An 8x8 font is assumed. The CHR(newy+128) is a "command" that we will
' ' be using to communicate back to FLAG.PPE the position of the file being
' ' selected via mouse click.
' IF (rip) THEN
' MOUSEREG 0,1,newy,13,newy+1,8,8,TRUE,FALSE," "+CHR(newy+128)
' ENDIF
' INC newy
' ENDIF
'ENDWHILE
'
'' finish up the mouse region definitions
'IF (rip) THEN
' MPRINT "!|#|#|#"+CR+chr(10)
'ENDIF
'RETURN